package com.north.light.androidutils.permission;

import android.app.Activity;
import android.os.Bundle;

import com.north.light.androidutils.R;
import com.north.light.androidutils.gson.GsonUtils;
import com.north.light.androidutils.log.LogUtil;
import com.north.light.libpermission.PermissionUtils;
import com.north.light.libpermission.api.PermissionCallback;
import com.north.light.libpermission.constant.Permission;

import java.util.List;

public class PermissionActivity extends PermissionBaseAct {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_permission);
        PermissionUtils.with(this)
                .key(1111)
                .request(new String[]{Permission.CAMERA})
                .setListener(new PermissionCallback() {
                    @Override
                    public void result(int type, int status, boolean grantAll) {
                        LogUtil.d("result： type" + type + " status: " + status + " grantAll: " + grantAll);
                    }

                    @Override
                    public void result(int type, int status, List<String> permissions, boolean grantAll) {
                        LogUtil.d("result2： type" + type + " status: " + status + " permissions: " + GsonUtils.getJsonStr(permissions) + " grantAll: " + grantAll);
                    }

                    @Override
                    public void error(int code) {
                        LogUtil.d("result2： error" + code);
                    }
                }).start();
    }

    @Override
    protected void test() {
        super.test();
        LogUtil.d("test");
    }
}